*%%.......................................................................................%%*

*"Is the Future Female? A Conjoint Experiment on Voter Preferences in Six Arab Countries" *

*Code Authors: Samuel Wakuma

*Lastupdated: Dec 27,2023

*%%.......................................................................................*%%*
*************************************************************************************************
*************************************************************************************************
* This  file prepares the  main datasets used for analysis ------->"IsFemaleFuture_Cleaned.dta" *
* It uses the raw version of "IsFemaleFuture_Cleaned.dta" and "ArabicEduc_translated.dta" files.*
*		    																						
*************************************************************************************************



* Set up working folders --- NB. Replace these with your own paths!
cd "C:\Users\xwaksa\Desktop\Repliction_Is the future female\Replication Package\Final_Replication_Package"

* Importing the raw data 
clear 
use "C:\Users\xwaksa\Desktop\Repliction_Is the future female\Replication Package\Final_Replication_Package\IsFemaleFuture_Raw.dta"


* =====================================================================


					* Preparing variables
*Experimental Attributes
* Gender of candidate
recode CandidateGender (1=0)(2=1)
label define cgender 1"Male" 0"Female"
label value  CandidateGender cgender

*Party Goals of Candidate
recode PartyGoals (1=0)(2=1)
label define pgoal 1 " National Economy" 0"Local Development"
label values  PartyGoals pgoal

*Competency
recode Competency (1=0)(2=1)
label define ccompt 1" Business" 0"CS0"
label values Competency ccompt

*Successful
recode Successful (1=0)(2=1)
label define succ 1"Successful" 0"No information"
label values Successful succ

**# 2)Outcome variables recoding#
**#2.1Vote*

recode EQ1 (98/99=.)

generate Vote_For=EQ1


**#2.2 mechanisms and Social desirablity biase recoding#


foreach var of varlist   EQ2 EQ3 EQ4 EQ5 EQ6 EQ7 EQ8 EQ9 EQ10 {
	recode `var' (98/99=.)

}
gen Would_Infl_Endorse =EQ2
gen Good_Raise_Funds=EQ3

gen Good_Improve_Security=EQ4

gen Good_Promote_Development=EQ5

gen Good_Social_Probs=EQ6

gen Improve_Ntnl_Econ=EQ7

gen Help_Obtain_Services=EQ8

gen Others_Would_Vote=EQ9

gen Likely_See_Similar_Candidate=EQ10


**#3 Respondent charachterstics 
recode Gender(3=.)(2=0)(1=1)
gen Respondent_Gender=Gender
label def fem 0" Female" 1"Male"
label values Respondent_Gender fem


recode Citizen(3=.)(2=0)(1=1)
label def cit 0" No" 1"Yes"
label values Citizen cit

recode Religiosity(98/99=.)
gen ln_Age=ln(Age)
label var ln_Age " log of Age"

**#3 Respondent charachterstics Education

*In order to include responses in the 'Other - specify' category, which were also provided in Arabic, we first translated them and created a sub-dataset for those respondents. Now, we are re-merging this sub-dataset with the master dataset.

merge 1:1 SbjNum using "Educ_translated.dta"

replace Educ_translated= upper( Educ_translated)


**# GENERATION OF NEW 4 EDUCATION_LEVEL*/
gen EDUCATION_LEVEL=.
replace EDUCATION_LEVEL=0 if Education==1 |Education==2|(strpos( Educ_translated , "STUD")) & strpos(Educ_translated, "SCHO") & !((strpos( Educ_translated , "DEGREE")|strpos( Educ_translated , "COLL")|strpos( Educ_translated , "UNIV"))) // primary and highscool combined



replace EDUCATION_LEVEL=1 if (strpos( Educ_translated , "DIPLOMA")|(strpos( Educ_translated , "BAC+")|(strpos( Educ_translated , "VOCA")|(strpos( Educ_translated , "baccalaureate")|(strpos( Educ_translated , "TECH")|(strpos( Educ_translated , "LICENS")|(strpos( Educ_translated , "CERT")|(strpos( Educ_translated , "INST"))))))))) & !strpos(Educ_translated, " DEGREE ") 
replace EDUCATION_LEVEL=1 if (strpos( Educ_translated , "DEGREE")|(strpos( Educ_translated , "COLL")|(strpos( Educ_translated , "UNIV")))) & (strpos( Educ_translated , "STUD"))|(strpos( Educ_translated , "FRESH"))|(strpos( Educ_translated , "SOPHOMORE"))|(strpos( Educ_translated , "YEAR"))

replace EDUCATION_LEVEL=2 if Education==3 | Education==4 |(strpos( Educ_translated , "DEGREE")) |(strpos( Educ_translated , " MASTER "))|(strpos( Educ_translated , "POSTGRA"))|(strpos( Educ_translated , "PHD"))|(strpos( Educ_translated , "ROFESSOR"))|(strpos( Educ_translated , "MS."))
  
  label define educationnn 0 " upto Highschool completed" 1" Tech_Vocational & Uni_Student" 2" Bachelor degree & above"
  label values EDUCATION_LEVEL educationnn

*four level edu*
gen EDU_4LEVEL=.
replace EDU_4LEVEL=0 if EDUCATION_LEVEL==0
replace EDU_4LEVEL=1 if EDUCATION_LEVEL==1
replace EDU_4LEVEL=2 if Education ==3
replace EDU_4LEVEL=2 if (strpos( Educ_translated , "DEGREE")) & !(strpos( Educ_translated , "MASTER"))
replace EDU_4LEVEL=3 if Education ==4
replace EDU_4LEVEL=3 if (strpos( Educ_translated , "DEGREE")) & (strpos( Educ_translated , "MASTER"))|(strpos( Educ_translated , "POSTGRA"))|(strpos( Educ_translated , "PHD"))|(strpos( Educ_translated , "ROFESSOR"))|(strpos( Educ_translated , "MS."))

  label define eduonnn 0 " upto Highschool completed" 1" Tech_Vocational & Uni_Student" 2" Bachelor degree " 3" Masters and Above"
  label values EDU_4LEVEL eduonnn

**#4*opinion about stereotype and practice recoding#
recode BizAppropriate(4/5=.)
recode CSOAppropriate (4/5=.)
recode BizAbility(4/5=.)
recode CSOAbility(4/5=.)
recode BenSexism(5/6=.)
recode HosSexism(5/6=.)
**#Sexism binary
gen BenSexismbi=.
replace BenSexismbi=1 if BenSexism==1|BenSexism==2
replace BenSexismbi=0 if BenSexism==3|BenSexism==4
label define sexism 1"BenYes" 0"BenNo"
label values BenSexismbi sexism

gen HosSexismbi=.
replace HosSexismbi=1 if HosSexism==1|HosSexism==2
replace HosSexismbi=0 if HosSexism==3|HosSexism==4
label define sexismh 1"HosYes" 0"HosNo"
label values HosSexismbi sexismh



*We piloted the survey in Saudi Arabia and Yemen as well, but the pilot data showed respondents in these countries do not view the vignette as realistic, so dropped!!
drop if Country==2|Country==7

**# Relable value for Country after droping Saudiarabia  * to make values sequential * "not mandatory"  unless for some specific appending issues while using outreg2
gen Country_new=.
replace Country_new=1 if Country==1
replace Country_new=2 if Country ==3
replace Country_new=3 if Country==4
replace Country_new=4 if Country==5
replace Country_new=5 if Country==6
replace Country_new=6 if Country==8

label define county 1"Egypt" 2" Algeria" 3" Morocco " 4"Jordan " 5"Tunisia" 6"Libya"
label value Country_new county

* Save the final cleaned file 

save "C:\Users\xwaksa\Desktop\Repliction_Is the future female\Replication Package\Final_Replication_Package\IsFemaleFuture_Cleaned.dta", replace
